<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core">

<ui:composition>
	<h:form id="generatorForm">
		<p:panel id="buttonPanel">

			<p:commandButton id="specifyButton" value="Specify SMTA to Generate"
				icon="ui-icon-pencil" onclick="specifyDialog.show()" />

			<p:progressBar widgetVar="pbAjax" ajax="true"
				value="#{generatorBean.progress}" labelTemplate="{value}%"
				styleClass="animated">
				<p:ajax event="complete" listener="#{generatorBean.onComplete}"
					update="messages"
					oncomplete="generateButton.enable(); specifyDialog.hide();" />
			</p:progressBar>

			<p:messages id="messages" showDetail="true" autoUpdate="true"
				escape="false" closable="false" />

			<p:blockUI block="messages"
				trigger=":specifyDialogForm:generateButton">
        		PROCESSING<br />
				<p:graphicImage value="resources/images/processing.gif" />
			</p:blockUI>
		</p:panel>
	</h:form>
	
	<p:dialog header="Specify SMTA ID and SHU Request ID" widgetVar="specifyDialog"
		modal="true" appendToBody="true" resizable="false" width="300"
		showEffect="#{uiConfigBean.dialogShowEffect}"
		hideEffect="#{uiConfigBean.dialogHideEffect}">
		<h:form id="specifyDialogForm">
			<h:panelGrid id="specifyDisplay" columns="2" cellpadding="2">
				<h:outputText value="MTA Type:" />
				<p:selectOneMenu value="#{generatorBean.mtaType}">  
		            <f:selectItem itemLabel="Select One" itemValue="" />
		            <f:selectItem itemLabel="SMTA" itemValue="0" />
		            <f:selectItem itemLabel="SMTA + IMTA1" itemValue="1" />
		            <f:selectItem itemLabel="SMTA + IMTA2" itemValue="2" />
	        	</p:selectOneMenu>

				<h:outputText value="SMTA ID:" />
				<h:inputText id="smtaId" label="smtaId"
					value="#{generatorBean.smtaId}" required="true" redisplay="true"
					size="20" />

				<h:outputText value="SHU Request ID:" />
				<h:inputText id="shuRequestId" label="shuRequestId" value="#{generatorBean.shuRequestId}"
					required="true" redisplay="true" size="20" />

				<h:outputText value="" />
				<p:commandButton id="generateButton" value="Generate PDF"
					actionListener="#{generatorBean.generate}"
					onclick="pbAjax.start(); generateButton.disable();"
					widgetVar="generateButton" />

			</h:panelGrid>
		</h:form>
	</p:dialog>
</ui:composition>

</html>
